//
// Created by Lenovo on 2020/8/27.
//
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using  namespace std;
const int maxn = 1e5+10;
int tree[maxn*32][2];
int num[maxn*32];
int a[maxn];
int rt = 1;
void build(int x)
{
    int u = 0;
    while(x)
    {
        int v = x%2;
        x = x/2;
        if(!tree[u][v])
        {
            memset(tree[rt],0,sizeof(tree[rt]));
            num[rt] = 0;
            tree[u][v] = rt++;
        }
        u = tree[u][v];
        num[u]++;
    }
}
int find(int x)
{
    int u = 0;
    int ans = 0;
    while(x)
    {
        int v = x%2;
        x = x/2;
        u = tree[u][v];
    }
    ans = num[u]-1;
    return ans;
}
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        memset(tree,0,sizeof(tree));
        memset(num,0,sizeof(num));
        for(int i = 0;i<n;i++)
        {
            scanf("%d",&a[i]);
            build(a[i]);
        }
        for(int i = 0;i<n;i++) printf("%d\n",find(a[i]));
        //for(int i = 0;i<=rt;i++) printf("rt = %d %d\n",i,num[i]);
    }
}

